/**
 *
 */
import * as api from '../../api/index';
import { Notification } from 'element-ui';
const state = {
   data: [], //列表数据
   query: {},
   page: {}, //分页数据
   loading: false //加载状态
}

const actions = {
   //获取菜单列表
   getData({ commit }, params) {
      commit('update', { type: 'loading', data: true });
      api.shixue.getData(params, res => {
         commit('update', { type: 'loading', data: false });
         if (res.status == 1) {
            commit('update', { type: 'query', data: params }); //更新查询数据
            commit('update', { type: 'data', data: res.data }); //更新列表数据
            commit('update', { type: 'page', data: res.page }); //更新分页数据
         } else Notification(res);
      });
   },

}

const mutations = {
   update(state, p) {
      state[p.type] = p.data;
   },
   del(state, str) { //删除数据
      eval(str);
   }
}

export default {
   namespaced: true,
   state,
   actions,
   mutations
}
